// ActionScript file

package framework
{
	import framework.async.ChainResponder;
	import framework.async.chainInternal;

	import mx.rpc.AsyncToken;

	public function chain(... args):AsyncToken
	{
		if (!args.length)
			return null;
		if (args.length % 2 != 0)
			throw new ArgumentError("Invalid number of arguments");

		var responder:ChainResponder = new ChainResponder;
		responder.chain = args;
		chainInternal(responder);
		return responder.token;
	}
}
